<!DOCTYPE html>
<html lang="zh-CN">
{% from 'bootstrap/utils.html' import render_messages %}
{% from 'bootstrap/form.html' import render_form %}
{% from 'bootstrap/form.html' import render_field, render_form_row %}
<head>
    <meta charset="UTF-8">
    <title>{{ config.SITE_NAME }}_后台管理中心</title>
    <base href="{{ request.headers['Host'] }}"/>
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta http-equiv="x-ua-compatible" content="ie=edge">
    <meta name="robots" content="nofollow"/>
    <!-- Font Awesome Icons -->
    <link rel="stylesheet"
          href="{{ url_for('admins.static', filename='lte/plugins/sweetalert2-theme-bootstrap-4/bootstrap-4.min.css') }}">
    <link rel="stylesheet"
          href="{{ url_for('admins.static', filename='lte/plugins/fontawesome-free/css/all.min.css') }}">
    <link rel="stylesheet" href="{{ url_for('admins.static', filename='lte/plugins/select2/css/select2.min.css') }}">
    <link rel="stylesheet"
          href="{{ url_for('admins.static', filename='lte/plugins/select2-bootstrap4-theme/select2-bootstrap4.min.css') }}">
    <link rel="stylesheet"
          href="{{ url_for('admins.static', filename='lte/plugins/overlayScrollbars/css/OverlayScrollbars.min.css') }}">
    <link rel="stylesheet"
          href="{{ url_for('admins.static', filename='lte/plugins/overlayScrollbars/css/OverlayScrollbars.min.css') }}">
    <link rel="stylesheet"
          href="{{ url_for('admins.static', filename='lte/plugins/icheck-bootstrap/icheck-bootstrap.min.css') }}">
    <!-- Theme style -->
    <link rel="stylesheet" href="{{ url_for('admins.static', filename='lte/style/css/adminlte.min.css') }}">
    <style>
        .ck-content {
            min-height: 390px;
        }
    </style>
</head>
<body class="hold-transition sidebar-mini layout-fixed layout-footer-fixed">
<div class="wrapper">
    {% include 'base/aside.html' %}
    <!-- Content Wrapper. Contains page content -->
    <div class="content-wrapper">
        <div class="content-header">
            <div class="container-fluid">
                <div class="row mb-2">
                    <div class="col-sm-6">
                        <a class="ml-2" data-widget="pushmenu" href="#"><i class="fas fa-bars"></i></a>
                        <a href="javascript:;" onClick="javascript:history.back(-1);" class="ml-3"><i
                                class="fas fa-angle-left"></i></a>
                    </div><!-- /.col -->
                    <div class="col-sm-6">
                        <ol class="breadcrumb float-sm-right">
                            <li class="breadcrumb-item"><a href="{{ url_for('admins.dashboard') }}">主页</a></li>
                            <li class="breadcrumb-item active">{{ page_title }}</li>
                        </ol>
                    </div><!-- /.col -->
                </div><!-- /.row -->
            </div><!-- /.container-fluid -->
        </div>


        <!-- Main content -->

        <div class="content">
            <div class="container-fluid">
                {{ render_messages() }}
                <form method="post" action="">
                    <div class="row">
                        <div class="col-9">
                            <div class="card">
                                <div class="card-body">
                                    {{ render_field(form.title, form_type='horizontal', horizontal_columns=('lg', 1,
                                    11)) }}
                                    {{ render_field(form.original_title, form_type='horizontal',
                                    horizontal_columns=('lg', 1, 11)) }}
                                    {{ render_field(form.thumbnail, form_type='horizontal', horizontal_columns=('lg', 1,
                                    11)) }}
                                    {{ render_field(form.content, form_type='horizontal', horizontal_columns=('lg', 1,
                                    11)) }}
                                    {{ render_field(form.description, form_type='horizontal', horizontal_columns=('lg',
                                    1, 11)) }}
                                    {{ render_field(form.keyword, form_type='horizontal', horizontal_columns=('lg', 1,
                                    11)) }}
                                </div>
                            </div>
                        </div>
                        <div class="col-3">
                            <div class="card">
                                <div class="card-body">
                                    {{ render_field(form.category_id) }}
                                    {{ render_field(form.source) }}
                                    {{ render_field(form.author) }}
                                    <div class="form-group">
                                        <label>TAGS</label>(多个Tag用中文 ，分割)
                                        <button type="button"
                                                class="btn btn-light btn-sm"
                                                onclick="openWin('{{ url_for('admins.article_pull_tags') }}')">
                                            标签库
                                        </button>
                                        {% if form.tags.errors %}
                                        {{ form.tags(class='form-control is-invalid') }}
                                        {% else %}
                                        {{ form.tags(class='form-control') }}
                                        {% endif %}
                                        {% for message in form.tags.errors %}
                                        <div class="invalid-feedback d-block">{{ message }}</div>
                                        {% endfor %}
                                    </div>
                                    {{ render_field(form.hot) }}
                                    <div class="row mb-3">
                                        <div class="ml-3 icheck-primary">
                                            {{ form.focus(class='form-check-input')}}
                                            {{ form.focus.label(class='form-check-label')}}
                                        </div>
                                        <div class="ml-3 icheck-primary">
                                            {{ form.top(class='form-check-input')}}
                                            {{ form.top.label(class='form-check-label')}}
                                        </div>
                                        <div class="ml-3 icheck-primary">
                                            {{ form.good(class='form-check-input')}}
                                            {{ form.good.label(class='form-check-label')}}
                                        </div>
                                    </div>
                                    <div class="row mt-3">
                                        <div class="col">
                                            <input class="btn btn-success btn-block" id="save" name="save" type="submit" value="发布">
                                            <a class="btn btn-danger btn-block" type="button" href="{{ jump_for_up }}">返回</a>
                                        </div>
                                    </div>
                                    
                                    {{- form.csrf_token -}}
                                </div>
                            </div>

                        </div>
                    </div>
                </form>
            </div>
        </div>
        <!-- /.content -->
    </div>
    <!-- /.content-wrapper -->

    <!-- Main Footer -->
    <footer class="main-footer">
        <!-- To the right -->
        <div class="float-right d-none d-sm-inline">
            空谈误国实干兴邦
        </div>
        <!-- Default to the left -->
        <strong>河北鼎道网络技术有限公司出品</strong>
    </footer>
</div>
<!-- ./wrapper -->
<!-- REQUIRED SCRIPTS -->
<script src="{{ url_for('admins.static', filename='lte/plugins/jquery/jquery.min.js') }}"></script>
<script src="{{ url_for('admins.static', filename='lte/plugins/bootstrap/js/bootstrap.bundle.min.js') }}"></script>
<!-- AdminLTE App -->
<script src="{{ url_for('admins.static', filename='pjax/jquery.pjax.js') }}"></script>
<script src="{{ url_for('admins.static', filename='lte/plugins/sweetalert2/sweetalert2.min.js') }}"></script>
<script src="{{ url_for('admins.static', filename='lte/plugins/select2/js/select2.full.min.js') }}"></script>
<script src="{{ url_for('admins.static', filename='lte/plugins/overlayScrollbars/js/jquery.overlayScrollbars.min.js') }}"></script>
<script src="{{ url_for('admins.static', filename='lte/style/js/adminlte.min.js') }}"></script>
<script src="{{ url_for('admins.static', filename='ckeditor/fun/ckeditor.js') }}"></script>
<script>
ClassicEditor.create(
    document.querySelector('#content'),
    {
        toolbar: {
            items: [
                'undo',
                'redo',

                '|',
                'bold',
                'italic',
                'link',
                'alignment',
                'bulletedList',
                'numberedList',
                '|',
                'imageUpload',
                'blockQuote',
                'insertTable',
                'mediaEmbed',
                '|',
                'removeFormat',
                'heading'
            ]
        },
        language: 'zh-cn',
        image: {
            toolbar: [
                'imageTextAlternative',
                'imageStyle:full',
                'imageStyle:side'
            ],
            types: ['jpeg']
        },
        table: {
            contentToolbar: [
                'tableColumn',
                'tableRow',
                'mergeTableCells'
            ]
        },
        simpleUpload: {
            uploadUrl: '{{ url_for('admins.picture_upload') }}',
            headers: {
                'X-CSRFToken': '{{ csrf_token() }}'
            }
        }
    }
).then(
    editor => {
        window.editor = editor;
    }
).catch(
    error => {
        console.error( 'Oops, something gone wrong!' );
        console.error( 'Please, report the following error in the https://github.com/ckeditor/ckeditor5 with the build id and the error stack trace:' );
        console.warn( 'Build id: gwapzoedv1p0-hdd9bmuc5d3s' );
        console.error( error );
    }
);

$(function(){
    $('.select2').select2()
    //Initialize Select2 Elements
    $('.select2bs4').select2({
      theme: 'bootstrap4'
    })
})

$(document).pjax('a:not(.no-pjax)', '#pjax-container', {fragment:'#pjax-container', timeout:8000})

function openWin(url, w=720, h=600) {
       var iWidth=w;                          //弹出窗口的宽度;
       var iHeight=h;                         //弹出窗口的高度;
       //获得窗口的垂直位置
       var iTop = (window.screen.availHeight - 30 - iHeight) / 2;
       //获得窗口的水平位置
       var iLeft = (window.screen.availWidth - 10 - iWidth) / 2;
       window.open(url, name, 'height=' + iHeight + ',,innerHeight=' + iHeight + ',width=' + iWidth + ',innerWidth=' + iWidth + ',top=' + iTop + ',left=' + iLeft + ',status=no,toolbar=no,menubar=no,location=no,resizable=no,scrollbars=0,titlebar=no');
}

</script>
</body>
</html>
